package com.bckj.freshnow.order.trade.ons.producer;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.Producer;
import com.bckj.fastboot.core.jackson.JsonUtils;
import com.bckj.fastboot.mq.ons.AbstractOnsProducer;
import com.bckj.freshnow.common.constant.TradeOrderMQConstants;
import com.bckj.freshnow.order.model.TradeStatusChangeMsg;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class TradeStatusChangeOnsProducer extends AbstractOnsProducer<TradeStatusChangeMsg> {

    private Producer producer;

    @Override
    public Producer getProducer() {
        return producer;
    }

    @Override
    protected Message buildMessage(TradeStatusChangeMsg msg) {
        return new Message(TradeOrderMQConstants.TOPIC_STATUS_CHANGE, null, JsonUtils.toJsonStr(msg).getBytes());
    }

}
